From 417bf922a04f8b0d34e909fb1b691d70cbfebacd Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 1 Dec 2000 08:11:16 +0000 Subject: [PATCH] (fit-window-to-buffer): Handle non-nil `truncate-lines'. --- lisp/window.el | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lisp/window.el b/lisp/window.el index 86cb45f92e5..60ebba7f1f0 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -508,9 +508,17 @@ header-line." (let ((end (with-current-buffer buf (save-excursion (goto-char (point-max)) - (if (and (bolp) (not (bobp))) - (1- (point)) - (point)))))) + (when (and (bolp) (not (bobp))) + ;; Don't include final newline + (backward-char 1)) + (when truncate-lines + ;; If line-wrapping is turned off, test the + ;; beginning of the last line for visibility + ;; instead of the end, as the end of the line + ;; could be invisible by virtue of extending past + ;; the edge of the window. + (forward-line 0)) + (point))))) (set-window-vscroll window 0) (while (and (< desired-height max-height) (= desired-height (window-height window)) -- 2.30.2